<?php



class Query extends Database {

	
	
	public static function GetFilmsPourAffiche(){
        $semaine=Navig::getSemaineSelectionnee();
        $debut=Date::timestampToPattern($semaine['debut']);
        $fin=Date::timestampToPattern($semaine['fin']);
        $requete='SELECT * FROM film WHERE FILM_NUMID IN '.
                '(SELECT FILM_NUMID FROM programmation WHERE PROG_DATE '.
                "BETWEEN '$debut' AND '$fin')";
        return Film::populateList(self::query($requete));
	}

	
	
	public static function getFilmsPattern($pattern, $dansTitre=true){
        $champ=$dansTitre?'FILM_TITRE':'FILM_SYNOP';
        $requete="SELECT * FROM film WHERE $champ LIKE '$pattern'";
        return Film::populateList(self::query($requete));
	}
    
    
    
    public static function getSeancesDateHeure($date, $heure){
        $heureEnMinutes=Date::timeToMinutes($heure);
        $requete='select p.* from programmation p join creneau c on p.cren_numid=c.cren_numid '.
                  "where PROG_DATE='$date' and cren_heure>'$heureEnMinutes' union select * from ".
                  "programmation where PROG_DATE>'$date' order by PROG_DATE";
        return Programmation::populateList(self::query($requete));
    }

	
	
	public static function getProchainesProgs($film){
        $id=$film->FILM_NUMID;
        $requete="SELECT * FROM programmation WHERE FILM_NUMID='$id' and PROG_DATE>='".Date::nowSQL().
                "' ORDER BY PROG_DATE";
        return Programmation::populateList(self::query($requete));
	}
	
	
	public static function getPhotosDuFilm($film){
		$id=$film->FILM_NUMID;
        $requete="SELECT * FROM photo WHERE FILM_NUMID='$id'";
        return Photo::populateList(self::query($requete));
	}
	
	
	public static function getVideosDuFilm($film){
		$id=$film->FILM_NUMID;
        $requete="SELECT * FROM bande_annonce WHERE FILM_NUMID='$id'";
        return BandeAnnonce::populateList(self::query($requete));
	}


}

?>